<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        div{
            width: 200px;
            height: 200px;
            background-color: aqua;
            position: fixed;
            left: 500px;
            top: 200px;
        }
    </style>
</head>
<body>
    <div></div>
    <script>
        let div=document.querySelector("div")
        document.onkeydown=function(e){
            let code=e.keyCode
            if(code==37){
                div.style.left=div.offsetLeft-10+"px"
            }else if(code==38){
                div.style.top=div.offsetTop-10+"px"
            }else if(code==39){
                div.style.left=div.offsetLeft+10+"px"
            }else if(code==40){
                div.style.top=div.offsetTop+10+"px"
            }
        }
    </script>
</body>
</html>